<%--
  Created by IntelliJ IDEA.
  User: xiaoding
  Date: 2021/1/8
  Time: 16:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>图书类型</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/bootstrap-3.3.7-dist/css/Style.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/bootstrap-3.3.7-dist/css/index.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/bootstrap-3.3.7-dist/css/search.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/bootstrap-3.3.7-dist/css/popupWin.css">
    <script src="${pageContext.request.contextPath}/bootstrap-3.3.7-dist/js/JQuery.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/bootstrap-3.3.7-dist/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
    <script>
        $(function () {
            //添加图书类型
            $(".addBook").click(function () {
                //清空内容
                $("#bNames").text("");
                //将窗口显示
                $("#popupWins").css("display","block");
                //修改表单提交路径
                $("#popupWins").attr("action","NextBookTypeServlet?flag=add");
                //修改标题
                $("#updateTitle").text("添加图书类型");
            });

            //图书类型搜索
            $(".span-right").click(function () {
                //判断内容是否为空
                if ($("#search").val() != "") {
                    window.location.href = "NextBookTypeServlet?flag=search&bName="+$("#search").val();
                }else {
                    window.location.href = "NextBookTypeServlet?flag=select";
                }
            });

            //关闭窗口
            $(".exit").click(function () {
                $("#popupWins").css("display","none");
            });
        })
        //图书修改
        function updateBookType(bId,bName) {
            //将窗口显示
            $("#popupWins").css("display","block");
            //修改表单提交路径
            $("#popupWins").attr("action","NextBookTypeServlet?flag=update");
            //修改标题
            $("#updateTitle").text("修改图书类型");
            //赋值
            $("#bNames").val(bName);
            $("#bId").val(bId);
        }
    </script>
</head>
<body>
    <%-- 头部 开始 --%>
    <jsp:include page="head.jsp"/>
    <%-- 头部 结束 --%>

    <%-- 主体 开始 --%>
    <div class="main">
        <%-- 主体左边 开始 --%>
        <jsp:include page="left.jsp"/>
        <%-- 主体左边 结束 --%>

        <%-- 主体右边 开始 --%>
        <div class="main-right">
            <%-- 主体右边头部 开始 --%>
            <div class="main-right-top">
                <div>
                    <h3>图书类型>查询</h3>
                </div>

                <div class="main-right-top-bottom">
                    <span class="span-left">图书名称</span>
                    <input type="text" name="search" id="search"/>
                    <span class="span-right">搜索</span>
                    <span class="addBook">添加图书类型</span>
                </div>
            </div>
            <%-- 主体右边头部 结束 --%>

            <%-- 内容 开始  --%>
            <div class="main-right-bottom">
                <table class="table table-bordered">
                    <tr class="trTitle">
                        <th>图书类型Id</th>
                        <th>图书类型名称</th>
                        <th>操作</th>
                    </tr>
                    <c:forEach items="${requestScope.bookType}" var="list">
                        <tr>
                            <th>${list.bId}</th>
                            <th>${list.bName}</th>
                            <th>
                                <a onclick="updateBookType('${list.bId}','${list.bName}')"; href="#">修改</a>
                            </th>
                        </tr>
                    </c:forEach>
                </table>
            </div>
            <%-- 内容 结束  --%>

            <%-- 分页 开始 --%>
            <div class="page">
                ${requestScope.pageUtil}
            </div>
            <%-- 分页 结束 --%>
        </div>
        <%-- 主体右边 结束 --%>
    </div>
    <%-- 主体 结束 --%>

    <%-- 尾部 开始 --%>
    <jsp:include page="footer.jsp"/>
    <%-- 尾部 结束 --%>

    <%-- 信息窗口 开始 --%>
    <form class="popupWins" method="post" id="popupWins">
        <h3 id="updateTitle">图书类型操作</h3>
        <div class="popupWinInputs">
            <input type="hidden" value="${param.page}" name="page" id="page">
            <input type="hidden" value="${param.bName}" name="bName" id="bName">
            <input type="hidden" value="" name="bId" id="bId">
            <p>
                <span>图书类型名称：</span>
                <input type="text" required="required" name="bNames" id="bNames">
            </p>
        </div>
        <hr>
        <div class="popupWinButtons">
            <input type="submit" value="确定">
            <input type="button" class="exit" value="关闭">
        </div>
    </form>
    <%-- 信息窗口 结束 --%>
</body>
</html>
